|
1
|
|
|
/* |
|
2
|
|
|
* Circles - Bring cloud-users closer together. |
|
3
|
|
|
* |
|
4
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
|
5
|
|
|
* later. See the COPYING file. |
|
6
|
|
|
* |
|
7
|
|
|
* @author Maxence Lange <[email protected]> |
|
8
|
|
|
* @copyright 2017 |
|
9
|
|
|
* @license GNU AGPL version 3 or any later version |
|
10
|
|
|
* |
|
11
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
12
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
13
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
14
|
|
|
* License, or (at your option) any later version. |
|
15
|
|
|
* |
|
16
|
|
|
* This program is distributed in the hope that it will be useful, |
|
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19
|
|
|
* GNU Affero General Public License for more details. |
|
20
|
|
|
* |
|
21
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
22
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
23
|
|
|
* |
|
24
|
|
|
*/ |
|
25
|
|
|
|
|
26
|
|
|
/** global: OC */ |
|
27
|
|
|
/** global: OCA */ |
|
28
|
|
|
/** global: Notyf */ |
|
29
|
|
|
|
|
30
|
|
|
|
|
31
|
|
|
/** global: nav */ |
|
32
|
|
|
/** global: actions */ |
|
33
|
|
|
/** global: elements */ |
|
34
|
|
|
/** global: results */ |
|
35
|
|
|
|
|
36
|
|
|
|
|
37
|
|
|
var api = OCA.Circles.api; |
|
38
|
|
|
var curr = { |
|
39
|
|
|
circlesType: '', |
|
40
|
|
|
circle: 0, |
|
41
|
|
|
circleName: '', |
|
42
|
|
|
circleLevel: 0, |
|
43
|
|
|
circleStatus: '', |
|
44
|
|
|
circleMembers: {}, |
|
45
|
|
|
circleLinks: {}, |
|
46
|
|
|
searchCircle: '', |
|
47
|
|
|
searchFilter: 0, |
|
48
|
|
|
searchUser: '', |
|
49
|
|
|
allowed_federated: 0, |
|
50
|
|
|
allowed_circles: 0, |
|
51
|
|
|
|
|
52
|
|
|
defineCircle: function (data) { |
|
53
|
|
|
curr.circle = data.circle_id; |
|
54
|
|
|
curr.circleName = data.details.name; |
|
55
|
|
|
curr.circleSettings = data.details.settings; |
|
56
|
|
|
curr.circleLevel = data.details.user.level; |
|
57
|
|
|
curr.circleStatus = data.details.user.status; |
|
58
|
|
|
} |
|
59
|
|
|
}; |
|
60
|
|
|
|
|
61
|
|
|
var define = { |
|
62
|
|
|
levelMember: 1, |
|
63
|
|
|
levelModerator: 4, |
|
64
|
|
|
levelAdmin: 8, |
|
65
|
|
|
levelOwner: 9, |
|
66
|
|
|
linkRemove: 0, |
|
67
|
|
|
linkDown: 1, |
|
68
|
|
|
linkSetup: 2, |
|
69
|
|
|
linkRefused: 4, |
|
70
|
|
|
linkRequestSent: 5, |
|
71
|
|
|
linkRequested: 6, |
|
72
|
|
|
linkUp: 9, |
|
73
|
|
|
animationSpeed: 100, |
|
74
|
|
|
animationMenuSpeed: 60, |
|
75
|
|
|
|
|
76
|
|
|
linkStatus: function (status) { |
|
77
|
|
|
s = { |
|
|
|
|
|
|
78
|
|
|
0: t('circles', 'Link Removed'), |
|
79
|
|
|
1: t('circles', 'Link down'), |
|
80
|
|
|
2: t('circles', 'Setting link'), |
|
81
|
|
|
4: t('circles', 'Request dismissed'), |
|
82
|
|
|
5: t('circles', 'Request sent'), |
|
83
|
|
|
6: t('circles', 'Link requested'), |
|
84
|
|
|
9: t('circles', 'Link up') |
|
85
|
|
|
}; |
|
86
|
|
|
|
|
87
|
|
|
return s[parseInt(status)]; |
|
88
|
|
|
} |
|
89
|
|
|
}; |
|
90
|
|
|
|
|
91
|
|
|
|
|
92
|
|
|
$(document).ready(function () { |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* @constructs Navigation |
|
96
|
|
|
*/ |
|
97
|
|
|
var Navigation = function () { |
|
98
|
|
|
|
|
99
|
|
|
$.extend(Navigation.prototype, curr); |
|
100
|
|
|
$.extend(Navigation.prototype, nav); |
|
101
|
|
|
$.extend(Navigation.prototype, elements); |
|
102
|
|
|
$.extend(Navigation.prototype, actions); |
|
103
|
|
|
$.extend(Navigation.prototype, settings); |
|
|
|
|
|
|
104
|
|
|
$.extend(Navigation.prototype, resultCircles); |
|
|
|
|
|
|
105
|
|
|
$.extend(Navigation.prototype, resultMembers); |
|
|
|
|
|
|
106
|
|
|
$.extend(Navigation.prototype, resultLinks); |
|
|
|
|
|
|
107
|
|
|
|
|
108
|
|
|
this.init(); |
|
109
|
|
|
this.initTransifex(); |
|
110
|
|
|
this.retrieveSettings(); |
|
111
|
|
|
}; |
|
112
|
|
|
|
|
113
|
|
|
|
|
114
|
|
|
Navigation.prototype = { |
|
115
|
|
|
|
|
116
|
|
|
init: function () { |
|
117
|
|
|
elements.initElements(); |
|
118
|
|
|
elements.initUI(); |
|
119
|
|
|
elements.initTweaks(); |
|
120
|
|
|
elements.initAnimationNewCircle(); |
|
121
|
|
|
elements.initExperienceCirclesList(); |
|
122
|
|
|
elements.initExperienceCircleButtons(); |
|
123
|
|
|
//elements.initExperienceMemberDetails(); |
|
124
|
|
|
nav.initNavigation(); |
|
125
|
|
|
}, |
|
126
|
|
|
|
|
127
|
|
|
initTransifex: function () { |
|
128
|
|
|
t('circles', 'Personal Circle'); |
|
129
|
|
|
t('circles', 'Hidden Circle'); |
|
130
|
|
|
t('circles', 'Private Circle'); |
|
131
|
|
|
t('circles', 'Public Circle'); |
|
132
|
|
|
|
|
133
|
|
|
t('circles', 'Personal'); |
|
134
|
|
|
t('circles', 'Hidden'); |
|
135
|
|
|
t('circles', 'Private'); |
|
136
|
|
|
t('circles', 'Public'); |
|
137
|
|
|
|
|
138
|
|
|
t('circles', 'Not a member'); |
|
139
|
|
|
t('circles', 'Member'); |
|
140
|
|
|
t('circles', 'Moderator'); |
|
141
|
|
|
t('circles', 'Admin'); |
|
142
|
|
|
t('circles', 'Owner'); |
|
143
|
|
|
|
|
144
|
|
|
t('circles', 'Unknown'); |
|
145
|
|
|
t('circles', 'Invited'); |
|
146
|
|
|
t('circles', 'Requesting'); |
|
147
|
|
|
t('circles', 'Blocked'); |
|
148
|
|
|
t('circles', 'Kicked'); |
|
149
|
|
|
}, |
|
150
|
|
|
|
|
151
|
|
|
retrieveSettings: function () { |
|
152
|
|
|
var self = this; |
|
153
|
|
|
|
|
154
|
|
|
$.ajax({ |
|
155
|
|
|
method: 'GET', |
|
156
|
|
|
url: OC.generateUrl('/apps/circles/settings'), |
|
157
|
|
|
}).done(function (result) { |
|
158
|
|
|
self.retrieveSettingsResult(result) |
|
|
|
|
|
|
159
|
|
|
}).fail(function () { |
|
160
|
|
|
self.retrieveSettingsResult({status: -1}); |
|
161
|
|
|
}); |
|
162
|
|
|
}, |
|
163
|
|
|
|
|
164
|
|
|
retrieveSettingsResult: function (result) { |
|
165
|
|
|
if (result.status !== 1) { |
|
166
|
|
|
return; |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
curr.allowed_federated = result.allowed_federated; |
|
170
|
|
|
curr.allowed_circles = result.allowed_circles; |
|
171
|
|
|
|
|
172
|
|
|
var circleId = window.location.hash.substr(1); |
|
173
|
|
|
if (circleId) { |
|
174
|
|
|
actions.selectCircle(circleId); |
|
175
|
|
|
} |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
}; |
|
179
|
|
|
|
|
180
|
|
|
|
|
181
|
|
|
/** |
|
182
|
|
|
* @constructs Notification |
|
183
|
|
|
*/ |
|
184
|
|
|
var Notification = function () { |
|
185
|
|
|
this.initialize(); |
|
186
|
|
|
}; |
|
187
|
|
|
|
|
188
|
|
|
Notification.prototype = { |
|
189
|
|
|
|
|
190
|
|
|
initialize: function () { |
|
191
|
|
|
|
|
192
|
|
|
//noinspection SpellCheckingInspection |
|
193
|
|
|
var notyf = new Notyf({ |
|
194
|
|
|
delay: 5000 |
|
195
|
|
|
}); |
|
196
|
|
|
|
|
197
|
|
|
this.onSuccess = function (text) { |
|
198
|
|
|
notyf.confirm(text); |
|
199
|
|
|
}; |
|
200
|
|
|
|
|
201
|
|
|
this.onFail = function (text) { |
|
202
|
|
|
notyf.alert(text); |
|
203
|
|
|
}; |
|
204
|
|
|
|
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
}; |
|
208
|
|
|
|
|
209
|
|
|
OCA.Circles.Navigation = Navigation; |
|
210
|
|
|
OCA.Circles.navigation = new Navigation(); |
|
211
|
|
|
|
|
212
|
|
|
OCA.Notification = Notification; |
|
213
|
|
|
OCA.notification = new Notification(); |
|
214
|
|
|
|
|
215
|
|
|
}); |
|
216
|
|
|
|
|
217
|
|
|
|